$(document).ready(function() {
	$(".globle_nav li span").click(function() {
		$(this).parent("li").toggleClass("hover").children(".tab_box").toggleClass("tab_box_hover");
		$(this).parent("li").siblings("li").removeClass("hover").children(".tab_box").removeClass("tab_box_hover");
		$('body').one('click', function() {
			$(".globle_nav li").removeClass("hover");
			$(".tab_box").removeClass("tab_box_hover")
		});
		return false
	});	
	$(".toggle_search_ico").click(function() {
		$(this).next(".search").show(100);
		$('body').one('click', function() {
			$(".toggle_search_bar").hide(100)
		});
		return false
	});
	$(".toggle_search_bar,.globle_nav_list").click(function(e) {
		e.stopPropagation()
	});
	$(".show_language").hover(function() {
		$(this).toggleClass("lhover")
	}, function() {
		$(this).removeClass("lhover")
	});
	$(".globle_nav_list_selector p").hover(function() {
		var j = $(this).index();
		$(this).addClass("hover").siblings("p").removeClass("hover").parent(".globle_nav_list_selector").siblings(".globle_nav_list_box").find(".globle_nav_box").eq(j).addClass("globle_nav_box_hover").siblings(".globle_nav_box").removeClass("globle_nav_box_hover")
	});
	var tabsTop = $(".header").outerHeight();
	$(window).scroll(function() {
		if ($(document).scrollTop() > tabsTop) {
			$(".follow_header").addClass("follow_header_hover");
			$(".follow_header").css({
				position: 'fixed'
			})
		} else {
			$(".follow_header").css({
				position: 'relative',
				top: 0
			});
			$(".follow_header").removeClass("follow_header_hover");
			$(".follow_header .globle_nav li").removeClass("hover");
			$(".follow_header .tab_box").removeClass("tab_box_hover")
		}
	});
	$(".detail-tabs li.tabs_name").click(function() {
		$(this).addClass("hover").siblings().removeClass("hover");
		var id = $(this).attr('id');
		if (id != 'detail') {
			$("#detail-info").hide()
		} else {
			$("#detail-info").show()
		}
		$("html,body").stop(true).animate({
			scrollTop: $("a[name='" + id + "']").offset().top - 47
		}, 1000)
	});
	$(document).tooltip({
		items: ".follow_ico,.choose_color,.tab_column_multi_level_tooltip,.product_slider_color_ico,.show_newslatter,.sw_cemail,.get_pb,.get_pb_disable,.tiptxt",
		position: {
			my: "center bottom-5",
			at: "center top",
			using: function(position, feedback) {
				$(this).css(position);
				$("<div>").addClass("arrow").addClass(feedback.vertical).addClass(feedback.horizontal).appendTo(this)
			}
		}
	});
	$(window).scroll(function() {
		if ($(window).scrollTop() >= 100) {
			$('#ScrollTopBtn').addClass("ui-scrolltop_hover")
		} else {
			$('#ScrollTopBtn').removeClass("ui-scrolltop_hover")
		}
	});
	$('#ScrollTopBtn').click(function() {
		$('html,body').animate({
			scrollTop: '0px'
		}, 400)
	});
	$("#feedbackbox").dialog({
		modal: true,
		resizable: false,
		width: 500,
		autoOpen: false,
		show: {
			effect: "blind",
			duration: 400
		},
		hide: {
			effect: "clip",
			duration: 400
		}
	});
	$("#feedback,.contant_us_btn").click(function() {
		$("#feedbackbox").dialog("open")
	});
	$("#subscribebox").dialog({
		modal: true,
		resizable: false,
		width: 300,
		autoOpen: false,
		show: {
			effect: "blind",
			duration: 400
		},
		hide: {
			effect: "clip",
			duration: 400
		}
	});
	$("#subscribe").click(function() {
		$("#subscribebox").dialog("open")
	});
	$(".pic_base").click(function() {
		$("#pic_base_img_box").dialog("open")
	});
	$("#pic_base_img_box").dialog({
		modal: true,
		resizable: false,
		width: "80%",
		autoOpen: false,
		show: {
			effect: "blind",
			duration: 400
		},
		hide: {
			effect: "clip",
			duration: 400
		}
	});
	$(".movie_ico").click(function() {
		$("#movie_box").dialog("open")
	});
	$("#movie_box").dialog({
		modal: true,
		resizable: false,
		width: 600,
		autoOpen: false,
		show: {
			effect: "blind",
			duration: 400
		},
		hide: {
			effect: "clip",
			duration: 400
		}
	});
	$("#support_rma").click(function() {
		$("#support_rma_form").dialog("open")
	});
	$("#support_rma_form").dialog({
		modal: true,
		resizable: false,
		width: "60%",
		autoOpen: false,
		show: {
			effect: "blind",
			duration: 400
		},
		hide: {
			effect: "clip",
			duration: 400
		}
	});
	$("#business_form").dialog({
		modal: true,
		resizable: false,
		width: "40%",
		autoOpen: false,
		show: {
			effect: "blind",
			duration: 400
		},
		hide: {
			effect: "clip",
			duration: 400
		}
	});
	$(".business_form_btn").click(function() {
		$("#business_form").dialog("open")
	})
});

function check_search() {
	var key = document.getElementById('keywords').value;
	if (key.length > 80) {
		alert('Search string must be less than 80 characters long.');
		return false
	}
	return true
}
jQuery.MessageShow = function(msg) {
	$("<div id='message'>" + msg + "</div>").appendTo("body").css("top", (($(window).height() / 2) + $(window).scrollTop()) - 83).css("left", ($(document).width() - 372) / 2).fadeIn("fast").delay(2000).fadeOut("slow", function() {})
}
$.fn.numeralinput = function() {
    $(this).css("ime-mode", "disabled");
    this.bind("keypress", function(e) {
        if (e.charCode === 0) return true; 
        var code = (e.keyCode ? e.keyCode : e.which);  
        return code >= 48 && code <= 57;
    });
    this.bind("blur", function() {
        if (!/\d+/.test(this.value)) {
            this.value = "";
        }
    });
    this.bind("paste", function() {
        if (window.clipboardData) {
            var s = clipboardData.getData('text');
            if (!/\D/.test(s)) {
                value = parseInt(s, 10);
                return true;
            }
        }
        return false;
    });
    this.bind("dragenter", function() {
        return false;
    });
    this.bind("keyup", function() {
        if (this.value !== '0' && /(^0+)/.test(this.value)) {
            this.value = parseInt(this.value, 10);
        }
    });
    this.bind("propertychange", function(e) {
        if (isNaN(this.value))
            this.value = this.value.replace(/\D/g, "");
    });
    this.bind("input", function(e) {
        if (isNaN(this.value))
            this.value = this.value.replace(/\D/g, "");
    });
};
/**/
